package com.kk.base.entity.admin;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import com.kk.base.entity.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import com.kk.base.annotion.ValidateEntity;

/**
 * 后台菜单实体类
 */
@EqualsAndHashCode(callSuper = true)
@Entity
@Table(name = "menu")
@EntityListeners(AuditingEntityListener.class)
@Data
public class Menu extends BaseEntity {

    private static final long serialVersionUID = 1L;

    /**
     * 菜单名称
     */
    @ValidateEntity(required = true, requiredLength = true, minLength = 1, maxLength = 18,
            errorRequiredMsg = "菜单名称不能为空!", errorMinLengthMsg = "菜单名称长度需大于1!",
            errorMaxLengthMsg = "菜单名称长度不能大于18!")
    @Column(name = "name", nullable = false, length = 18)
    private String name;

    /**
     * 菜单父分类
     */
    @ManyToOne
    @JoinColumn(name = "parent_id")
    private Menu parent;

    /**
     * 菜单url
     */
    @ValidateEntity(required = false)
    @Column(name = "url", length = 128)
    private String url;

    /**
     * 菜单图标icon
     */
    @ValidateEntity(required = false)
    @Column(name = "icon", length = 32)
    private String icon;

    /**
     * 菜单顺序，默认升序排列,默认是0
     */
    @Column(name = "sort", nullable = false, length = 4)
    private Integer sort = 0;

    /**
     * 是否是按钮
     */
    @Column(name = "is_bitton", nullable = false)
    private boolean isButton = false;

    /**
     * 是否显示
     */
    @Column(name = "is_show", nullable = false)
    private boolean isShow = true;

}
